package com.ymatou.iapi.couponmanage.old.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.couponmanage.old.parameter.CheckCouponExistsBean;
import com.ymatou.iapi.couponmanage.old.service.CheckCouponExistsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.sqlwapper.YmtCouponWapper;
/**
*确认优惠卷是否存在接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CheckCouponExists{
	private static CheckCouponExistsBean checkcouponexistsBean;
	private static CheckCouponExistsCall checkcouponexistsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("确认优惠卷是否存在接口");
	}

	@Before
	public void caseUp() {
		checkcouponexistsBean=new CheckCouponExistsBean();
		checkcouponexistsCall=new CheckCouponExistsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checkcouponexistsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_CheckCouponExists_001() {
		Logger.start(true,"正例-确认优惠卷存在");
		try {

			checkcouponexistsBean.setCouponCode(new YmtCouponWapper().selectTop1().getsCouponCode());
			checkcouponexistsCall.setData(checkcouponexistsBean);
			checkcouponexistsCall.callService();		
			
			Logger.verifyEquals("0", checkcouponexistsCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", checkcouponexistsCall.getMessage(), "验证返回Message");
			Logger.verifyEquals("true", checkcouponexistsCall.getIsExists(), "验证返回IsExists");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_CheckCouponExists_002() {
		Logger.start(true,"正例-确认优惠卷不存在");
		try {

			checkcouponexistsBean.setCouponCode("999999");
			checkcouponexistsCall.setData(checkcouponexistsBean);
			checkcouponexistsCall.callService();		
			
			Logger.verifyEquals("0", checkcouponexistsCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", checkcouponexistsCall.getMessage(), "验证返回Message");
			Logger.verifyEquals("false", checkcouponexistsCall.getIsExists(), "验证返回IsExists");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_CheckCouponExists_003() {
		Logger.start(true,"反例-CouponCode空");
		try {

			checkcouponexistsCall.setData(checkcouponexistsBean);
			checkcouponexistsCall.callService();			
			
			Logger.verifyEquals("0", checkcouponexistsCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", checkcouponexistsCall.getMessage(), "验证返回Message");
			Logger.verifyEquals("false", checkcouponexistsCall.getIsExists(), "验证返回IsExists");
	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}